#include "Preprocess.h"

string preprocess(const string& raw)
{
    unsigned int len = raw.length();
    string ret = "";
    for (int i = 0; i < len; i++)
    {
        if (raw.substr(i, 2) == "//")
        {
            while (raw[i] != '\n')++i;
            ++i;
        }
        else if (raw.substr(i, 2) == "/*")
        {
            i++;
            while (raw.substr(i, 2) != "*/")++i;
            ++i; ++i;
        }
        ret += raw[i];
    }
    return ret;
}

string ReadData(const string& filepath)
{
    ifstream infile;
    stringstream buffer;
    infile.open(filepath.data());
    assert(infile.is_open());
    buffer << infile.rdbuf();
    return preprocess(buffer.str());
}